package com.firstclass.controller;

import com.firstclass.entity.TakestudentEntity;
import com.firstclass.service.TakestudentService;
import com.firstclass.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-12-12 15:16:44
 */
@RestController
@RequestMapping("back/takestudent")
public class TakestudentController {
    @Autowired
    private TakestudentService takestudentService;

    /**
     * 查
     */
    @GetMapping("find_takestudent")
    public String findTakeCourse(String name, String num, String college,String profess) {
        return R.ok(takestudentService.queryByCondition(name, num, college, profess));
    }


    /**
     * 增，改
     */
    @PostMapping("save_takestudent")
    public String saveCourse(@RequestBody TakestudentEntity takestudentEntity) {
        takestudentService.save(takestudentEntity);
        return R.ok();
    }

    /**
     * 删
     */
    @PostMapping("del_takestudent")
    public String batchDel(@RequestBody List<Integer> ids) {
        takestudentService.removeByIds(ids);
        return R.ok();
    }

    /**
     * 学院人数
     */
    @GetMapping("college_nums")
    public String collegeNums() {
        return R.ok(takestudentService.collegeNums());
    }

}
